package com.qm.console.service.user.impl;

import com.qm.console.dao.mapper.IllegalKeywordDOMapper;
import com.qm.console.dao.mapper.IllegalRecordDOMapper;
import com.qm.console.dao.model.IllegalKeywordDO;
import com.qm.console.dao.model.IllegalRecordDO;
import com.qm.console.pubdef.dto.user.IllegalRecordQueryDTO;
import com.qm.console.service.user.IllegalService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * //                       _oo0oo_
 * //                      o8888888o
 * //                      88" . "88
 * //                      (| -_- |)
 * //                      0\  =  /0
 * //                    ___/`---'\___
 * //                  .' \\|     |// '.
 * //                 / \\|||  :  |||// \
 * //                / _||||| -:- |||||- \
 * //               |   | \\\  -  /// |   |
 * //               | \_|  ''\---/''  |_/ |
 * //               \  .-\__  '-'  ___/-. /
 * //             ___'. .'  /--.--\  `. .'___
 * //          ."" '<  `.___\_<|>_/___.' >' "".
 * //         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 * //         \  \ `_.   \_ __\ /__ _/   .-` /  /
 * //     =====`-.____`.___ \_____/___.-`___.-'=====
 * //                       `=---='
 * //
 * //
 * //     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * //
 * //               佛祖保佑         永无BUG
 * <p>
 * com.qm.console.service.user.impl
 * Created on 2020/11/27.
 */
@Service
public class IllegalServiceImpl implements IllegalService {

    @Autowired
    private IllegalRecordDOMapper illegalRecordDOMapper;
    @Autowired
    private IllegalKeywordDOMapper illegalKeywordDOMapper;

    @Override
    public List<IllegalRecordDO> list(IllegalRecordQueryDTO query) {
        return illegalRecordDOMapper.list(query);
    }

    @Override
    public int count(IllegalRecordQueryDTO query) {
        return illegalRecordDOMapper.count(query);
    }

    @Override
    public void setRead(List<Integer> ids) {
        illegalRecordDOMapper.setRead(ids);
    }

    @Override
    public List<IllegalKeywordDO> listKeywords() {
        return illegalKeywordDOMapper.list();
    }

    @Override
    public void addKeyword(String keyword) {
        IllegalKeywordDO item = new IllegalKeywordDO();
        item.setText(keyword);
        illegalKeywordDOMapper.insertSelective(item);
    }

    @Override
    public void deleteKeyword(Integer id) {
        illegalKeywordDOMapper.deleteByPrimaryKey(id);
    }
}
